<?php

namespace App\Http\Controllers\Outside;

use App\Http\Controllers\BaseController;
use App\Http\Validate\Outside\FileTranscodingValidate;
use App\Service\Outside\FileTranscoding\FileTranscodingService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use OSS\Core\OssException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class FileTranscodingController extends BaseController
{
    /**
     * @param Request $request
     * @return JsonResponse
     * @throws OssException
     * @throws ValidationException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function imageToWebp(Request $request): JsonResponse
    {
        FileTranscodingValidate::imageToWebpValidate($request->all());
        return $this->success(FileTranscodingService::imageToWebp($request));
    }
}
